//
//  AppDelegate+AppService.m
//  OnionHome
//
//  Created by fengjie on 2019/9/13.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "AppDelegate+AppService.h"
#import "GuideController.h"
#import <Bugly/Bugly.h>

@implementation AppDelegate (AppService)
#pragma mark ------初始化 window ----
-(void)initWindow{
    
     [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    DLogFunc;
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    if (![UserModelManager getGuideType]) {
        self.window.rootViewController = [[GuideController alloc] init];
    }else{
        [self setRootController];
    }
    
    [self.window makeKeyAndVisible];
    DLogFunc;
    [UIApplication sharedApplication].statusBarHidden = NO;
    DLogFunc;
    [self configurationSetting];
    DLogFunc;
    [self getVideos];
    DLogFunc;
}
-(void)setRootController{

    if ([UserModelManager getLoginType] ) {
        self.window.rootViewController = self.tabBarController;
    }else{
        self.window.rootViewController =[[BasseNavigationController alloc] initWithRootViewController:[LoginViewController new]];
    }
}

/// 第三方SDK配置
-(void)configurationSetting{
    //崩溃信息统计SDK
    [Bugly startWithAppId:@"3fd4d12432"];
    
}
/// 获取相册中视频
-(void)getVideos{
    
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
       NSArray * array = [Utilis getVideos];
     dispatch_async(dispatch_get_main_queue(), ^{
         [self.videoArray addObjectsFromArray:array];
         DLog(@"%lu",(unsigned long)self.videoArray.count);
     });
   });
}
@end
